<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>收到的简历</title>
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
    <style>
        body{margin: 10px;}
        .demo-carousel{height: 200px; line-height: 200px; text-align: center;}


        .layui-table-cell{
            text-align:center;
            height: auto;

            white-space: normal;
                              }

        .layui-table img{

            max-width:300px

        }
    </style>
</head>
<body>



<table class="layui-hide" id="demo" lay-filter="test"></table>


<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="tongzhi">通知</a>
    <a class="layui-btn layui-btn-xs" lay-event="jujue">拒绝</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>




<script src="layui/layui.all.js"></script>

<script>

    UrlParm = function() { // url参数
        var data, index;
        (function init() {
            data = [];
            index = {};
            var u = window.location.search.substr(1);
            if(u != '') {
                var parms = decodeURIComponent(u).replace(/&amp;/g, "&").split('&');
                for(var i = 0, len = parms.length; i < len; i++) {
                    if(parms[i] != '') {
                        var p = parms[i].split("=");
                        if(p.length == 1 || (p.length == 2 && p[1] == '')) { // p | p=
                            data.push(['']);
                            index[p[0]] = data.length - 1;
                        } else if(typeof(p[0]) == 'undefined' || p[0] == '') { // =c | =
                            data[0] = [p[1]];
                        } else if(typeof(index[p[0]]) == 'undefined') { // c=aaa
                            data.push([p[1]]);
                            index[p[0]] = data.length - 1;
                        } else { // c=aaa
                            data[index[p[0]]].push(p[1]);
                        }
                    }
                }
            }
        })();
        return {
            // 获得参数,类似request.getParameter()
            parm: function(o) { // o: 参数名或者参数次序
                try {
                    return(typeof(o) == 'number' ? data[o][0] : data[index[o]][0]);
                } catch(e) {}
            },
            //获得参数组, 类似request.getParameterValues()
            parmValues: function(o) { // o: 参数名或者参数次序
                try {
                    return(typeof(o) == 'number' ? data[o] : data[index[o]]);
                } catch(e) {}
            },
            //是否含有parmName参数
            hasParm: function(parmName) {
                return typeof(parmName) == 'string' ? typeof(index[parmName]) != 'undefined' : false;
            },
            // 获得参数Map ,类似request.getParameterMap()
            parmMap: function() {
                var map = {};
                try {
                    for(var p in index) {
                        map[p] = data[index[p]];
                    }
                } catch(e) {}
                return map;
            }
        }
    }();



    var pid=UrlParm.parm("pid");

    layui.use(['laydate', 'laypage', 'layer', 'table', 'form','carousel', 'upload', 'element', 'slider'], function(){
        var laydate = layui.laydate //日期
            ,laypage = layui.laypage //分页
            ,layer = layui.layer //弹层
            ,form = layui.form //表格
            ,table = layui.table //表格
            ,carousel = layui.carousel //轮播
            ,upload = layui.upload //上传
            ,element = layui.element //元素操作
            ,slider = layui.slider //滑块
        var $ = layui.$
        //向世界问个好
       // layer.msg('Hello World');

        //监听Tab切换
        element.on('tab(demo)', function(data){
            layer.tips('切换了 '+ data.index +'：'+ this.innerHTML, this, {
                tips: 1
            });
        });
        // var data={"code":0,"msg":"zzzz","count":1000,"data":[{"id":10000,"username":"user-0","sex":"女","city":"城市-0","sign":"签名-0","experience":255,"logins":24,"wealth":82830700,"classify":"作家","score":57},{"id":10001,"username":"user-1","sex":"男","city":"城市-1","sign":"签名-1","experience":884,"logins":58,"wealth":64928690,"classify":"词人","score":27},{"id":10002,"username":"user-2","sex":"女","city":"城市-2","sign":"签名-2","experience":650,"logins":77,"wealth":6298078,"classify":"酱油","score":31},{"id":10003,"username":"user-3","sex":"女","city":"城市-3","sign":"签名-3","experience":362,"logins":157,"wealth":37117017,"classify":"诗人","score":68},{"id":10004,"username":"user-4","sex":"男","city":"城市-4","sign":"签名-4","experience":807,"logins":51,"wealth":76263262,"classify":"作家","score":6},{"id":10005,"username":"user-5","sex":"女","city":"城市-5","sign":"签名-5","experience":173,"logins":68,"wealth":60344147,"classify":"作家","score":87},{"id":10006,"username":"user-6","sex":"女","city":"城市-6","sign":"签名-6","experience":982,"logins":37,"wealth":57768166,"classify":"作家","score":34},{"id":10007,"username":"user-7","sex":"男","city":"城市-7","sign":"签名-7","experience":727,"logins":150,"wealth":82030578,"classify":"作家","score":28},{"id":10008,"username":"user-8","sex":"男","city":"城市-8","sign":"签名-8","experience":951,"logins":133,"wealth":16503371,"classify":"词人","score":14},{"id":10009,"username":"user-9","sex":"女","city":"城市-9","sign":"签名-9","experience":484,"logins":25,"wealth":86801934,"classify":"词人","score":75}]};
        //执行一个 table 实例
        table.render({
            elem: '#demo'

           ,url: 'http://localhost:8080/toudi/getToudibyP', //数据接口
           //  ,title: '用户表'
            where:{'pid':pid}
           , method:'POST'
            ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                ,curr: 1 //设定初始在第 5 页
                ,groups: 1 //只显示 1 个连续页码
                // ,first: false //不显示首页
                // ,last: false //不显示尾页
                ,limits :10

            }

            ,totalRow: true //开启合计行
            ,cols: [[ //表头
                {type: 'checkbox',height: 40}
                ,{field:'name',title: '名字',templet:'<div>{{ d.jianli.name }}</div>', width: 90,}
                ,{field:'status',title: '状态',templet:'<div>{{ d.toudi.status }}</div>' ,width: 90,}

                ,{fixed: 'right', width: 400, align:'center', toolbar: '#barDemo'}
            ]]
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                ,layEvent = obj.event; //获得 lay-event 对应的值
            if(layEvent === 'detail'){
                location.href="jianliinfo.html?jid="+data.toudi.jid;
            }if(layEvent === 'tongzhi'){
                layer.open({
                    type: 2,
                    title: '发布面试邀请',
                    area: ['50%', '85%'] ,//自定义文本域宽高
                    content: 'pubyaoqing.html' ,//这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                    success: function (layero, index) {    //成功获得加载changefile.html时，预先加载，将值从父窗口传到 子窗口
                        //// console.log(obj.data.editAble);
                        let body = layer.getChildFrame('body', index);
                        //console.log(rowselect[0].filename);

                        body.find("#id").html(0);   //通过class名进行获取数据


                    }

                });

                layui.jquery.ajax({
                    url:"http://localhost:8080/toudi/upStatus",
                    data:{'id':data.toudi.id,"status":"已邀请"},
                    type:"Post",
                    success:function(result){
                        console.log(result);


                    },
                    error:function(result){
                        // $.messager.alert('错误',result.msg);
                    }
                });
            }if(layEvent === 'jujue'){
                layer.confirm('真的拒绝么', function(index){
                    obj.del(); //删除对应行（tr）的DOM结构
                    layui.jquery.ajax({
                        url:"http://localhost:8080/toudi/upStatus",
                        data:{'id':data.toudi.id,"status":"已拒绝"},
                        type:"Post",
                        success:function(result){
                            console.log(result);
                            layer.msg(result.msg);
                            location.reload(); //删除成功后再刷新
                        },
                        error:function(result){
                            // $.messager.alert('错误',result.msg);
                        }
                    });

                });
            } else if(layEvent === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del(); //删除对应行（tr）的DOM结构
                    layui.jquery.ajax({
                        url:"http://localhost:8080/toudi/delToudi",
                        data:{'id':data.toudi.id},
                        type:"Post",
                        success:function(result){
                            console.log(result);
                            layer.msg(result.msg);
                            // location.reload(); //删除成功后再刷新
                        },
                        error:function(result){
                            // $.messager.alert('错误',result.msg);
                        }
                    });
                    layer.close(index);
                    //向服务端发送删除指令
                });
            }
        });


        //分页
        laypage.render({
            elem: 'pageDemo' //分页容器的id
            ,count: 10 //总页数
            ,skin: '#1E9FFF' //自定义选中色值
            //,skip: true //开启跳页
            ,jump: function(obj, first){
                if(!first){
                    layer.msg('第'+ obj.curr +'页', {offset: 'b'});
                }
            }
        });


        //上传
        upload.render({
            elem: '#uploadDemo'
            ,url: '' //上传接口
            ,done: function(res){
                console.log(res)
            }
        });

        //滑块
        var sliderInst = slider.render({
            elem: '#sliderDemo'
            ,input: true //输入框
        });

        // //底部信息
        // var footerTpl = lay('#footer')[0].innerHTML;
        // lay('#footer').html(layui.laytpl(footerTpl).render({}))
        //     .removeClass('layui-hide');
    });
</script>
</body>
</html>
